<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue-extend</title>
    <link rel="stylesheet" href="../../../assets/css/bootstrap.min.css">
    <script src="../../../assets/js/vue-2.5.6.js"></script>
</head>

<body>
    <div id="app">
        <p>{{ num }}</p>
        <button @click="add(2)">增加</button>
        <btn @click.native="add(3)"></btn>
    </div>
</body>
<script>
    var btn = {
        template: '<button>外部组件</button>'
    }
    var app = new Vue({
        el: "#app",
        data: {
            num: 0
        },
        methods: {
            add: function(a) {
                return this.num += a;
            }
        },
        components: {
            "btn": btn
        },
    })
</script>

</html>